﻿package commands 
{
	import flash.utils.ByteArray;
	import commands.classesinfo.*;
	
	/**
	 * ...
	 * @author wwx
	 * 50000011 池信息
	 */
	public class PoolInfoCmd extends abCommand  
	{
		
		public function PoolInfoCmd() //: abCommand(CommandType.CMD_TYPE_ENTERROOM_RSP)  
		{
			super(CommandType(CommandType.CMD_TYPE_POOLINFO));
			pools = new Array();
		}
		
		public var msgSeq:int;//消息号
		public var errorNum:int;//错误号		
		
		public var deskId:int;//桌子id
		public var totalChipOfAllPool:int;//所有池总筹码数量
		public var gameOver:int;//游戏结束;0：否,1：是（游戏结束时，显示方式不一样）

		public var countOfPool:int;
		public var pools:Array;//Pool
		
		public function convertToCmd(bytes:ByteArray, offset:int, len:int):int
		{
			var ret:int = -1;
			msgSeq = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
			offset += 4;
			errorNum = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			
			deskId = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;			
			totalChipOfAllPool = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			gameOver = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			
			countOfPool = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			
			//pools = new Array();
			var pool:Pool = null;
			for (var i:int = 0; i < countOfPool; i++)
			{
				pool = new Pool();
				pool.poolId = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
				offset += 4;
				pool.count = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
				offset += 4;
				
				pools[i] = pool;
			}
			return 0;
		}			
	}
	
}